package Logic;

/**
 * Created by qq65827 on 2015/2/1.
 */
public class quickSort {

    public static void quick(int[] a, int low, int high) {
        if (low < high) {
            int middle = getMiddle(a, low, high);
            quick(a, low, middle - 1);
            quick(a, middle + 1, high);
        }
    }

// int a[] = {1, 32, 12, 45, 2345, 6345, 23, 3};
    public static int getMiddle(int[] a, int low, int high) {
        int temp = a[low];
        while (low < high) {
            while (low < high && a[high] > temp) {
                high--;
            }
            a[low] = a[high];
            while (low < high && a[low] < temp) {
                low++;
            }
            a[high] = a[low];
        }
        a[low] = temp;
        return low;

    }

}
